﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:ViewModels="clr-namespace:ScrumSprintMonitor.Modules.WorkItemMonitor.ViewModels">

    <Style x:Key="InfoLabel" TargetType="{x:Type TextBlock}">
        <Setter Property="FontSize" Value="64" />
        <Setter Property="FontWeight" Value="Light" />
        <Setter Property="Opacity" Value="0.7" />
        <Setter Property="VerticalAlignment" Value="Bottom" />
        <Setter Property="HorizontalAlignment" Value="Stretch" />
        <Setter Property="Foreground" Value="White" />
    </Style>

    <Style x:Key="NumericValueLabel" TargetType="{x:Type TextBlock}">
        <Setter Property="FontStyle" Value="Italic" />
        <Setter Property="FontSize" Value="64" />
        <Setter Property="VerticalAlignment" Value="Bottom" />
        <Setter Property="HorizontalAlignment" Value="Right" />
        <Setter Property="Foreground" Value="White" />
    </Style>

    <DataTemplate x:Key="HoursAvailableDataTemplate">
        <TextBlock>
            <TextBlock.Style>
                <Style TargetType="{x:Type TextBlock}" BasedOn="{StaticResource NumericValueLabel}">
                    <Setter Property="Text" Value="{Binding Path=AvailableHours, StringFormat='{}{0:N0} hours'}" />

                    <Style.Triggers>
                        <DataTrigger Binding="{Binding TimeIncludesFreeBusyInformation}" Value="False">
                            <Setter Property="Text" Value="{Binding Path=AvailableHours, StringFormat='≤ {0:N0} hours'}" />
                        </DataTrigger>
                    </Style.Triggers>
                </Style>
            </TextBlock.Style>
        </TextBlock>
    </DataTemplate>

    <DataTemplate DataType="{x:Type ViewModels:SprintStatsViewModel}">
        <StackPanel>
            <Grid HorizontalAlignment="Center">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto" SharedSizeGroup="ItemNameColumn" />
                    <ColumnDefinition Width="Auto" SharedSizeGroup="ItemValueColumn" />
                </Grid.ColumnDefinitions>
                
                <Grid.Style>
                    <Style TargetType="{x:Type Grid}">
                        <Setter Property="Visibility" Value="Visible"/>
                        
                        <Style.Triggers>
                            <DataTrigger Binding="{Binding ShowAverageResolutionTime}" Value="False">
                                <Setter Property="Visibility" Value="Collapsed"/>
                            </DataTrigger>
                        </Style.Triggers>
                    </Style>
                </Grid.Style>

                <TextBlock Grid.Column="0" Text="Average resolution time:" Style="{StaticResource InfoLabel}" />
                <TextBlock Grid.Column="1">
                    <TextBlock.Style>
                        <Style TargetType="{x:Type TextBlock}" BasedOn="{StaticResource NumericValueLabel}">
                            <Setter Property="Text" Value="{Binding AverageResolutionTime, StringFormat='{}{0:N0} hours'}" />

                            <Style.Triggers>
                                <DataTrigger Binding="{Binding AverageResolutionTime}" Value="NaN">
                                    <Setter Property="Text" Value="N/A" />
                                </DataTrigger>
                            </Style.Triggers>
                        </Style>
                    </TextBlock.Style>
                </TextBlock>
            </Grid>

            <Grid HorizontalAlignment="Center">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto" SharedSizeGroup="ItemNameColumn" />
                    <ColumnDefinition Width="Auto" SharedSizeGroup="ItemValueColumn" />
                </Grid.ColumnDefinitions>

                <TextBlock Grid.Column="0" Text="Time available:" Style="{StaticResource InfoLabel}" />
                <ContentControl Grid.Column="1" Content="{Binding}" ContentTemplate="{StaticResource HoursAvailableDataTemplate}" HorizontalAlignment="Right" Focusable="False" />
            </Grid>

            <Grid HorizontalAlignment="Center">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto" SharedSizeGroup="ItemNameColumn" />
                    <ColumnDefinition Width="Auto" SharedSizeGroup="ItemValueColumn" />
                </Grid.ColumnDefinitions>

                <Grid.Style>
                    <Style TargetType="{x:Type Grid}">
                        <Setter Property="Visibility" Value="Visible"/>

                        <Style.Triggers>
                            <DataTrigger Binding="{Binding ShowAheadOfScheduleBy}" Value="False">
                                <Setter Property="Visibility" Value="Collapsed"/>
                            </DataTrigger>
                        </Style.Triggers>
                    </Style>
                </Grid.Style>

                <TextBlock Grid.Column="0">
                    <TextBlock.Style>
                        <Style BasedOn="{StaticResource InfoLabel}" TargetType="{x:Type TextBlock}">
                            <Setter Property="Text" Value="Ahead of schedule by:"/>

                            <Style.Triggers>
                                <DataTrigger Binding="{Binding IsAheadOfSchedule}" Value="False">
                                    <Setter Property="Text" Value="Behind schedule by:" />
                                </DataTrigger>
                            </Style.Triggers>
                        </Style>
                    </TextBlock.Style>
                </TextBlock>
                <TextBlock Grid.Column="1" Text="{Binding DifferenceToSchedule, StringFormat=' {0:N0} hours'}" Foreground="{Binding AheadOfScheduleForegroundBrush}" Style="{StaticResource NumericValueLabel}" />
            </Grid>
        </StackPanel>
    </DataTemplate>
</ResourceDictionary>